#
# $Id$
#
# Copyright 2011, Juniper Networks, Inc.
# All rights reserved.
# This SOFTWARE is licensed under the LICENSE provided in the
# ../Copyright file. By downloading, installing, copying, or otherwise
# using the SOFTWARE, you agree to be bound by the terms of that
# LICENSE.

TEST_CASES_WITH_INPUT = \
REC/stand-2.7-1.xsl \
REC/test-10-1.xsl \
REC/test-11.2-1.xsl \
REC/test-11.2-2.xsl \
REC/test-11.2-3.xsl \
REC/test-11.2-4.xsl \
REC/test-11.2-5.xsl \
REC/test-11.2-6.xsl \
REC/test-12.2-1.xsl \
REC/test-12.2-2.xsl \
REC/test-15-1.xsl \
REC/test-16.1-1.xsl \
REC/test-16.1-2.xsl \
REC/test-2.3-1.xsl \
REC/test-2.3-2.xsl \
REC/test-5.2-1.xsl \
REC/test-5.2-10.xsl \
REC/test-5.2-11.xsl \
REC/test-5.2-12.xsl \
REC/test-5.2-13.xsl \
REC/test-5.2-14.xsl \
REC/test-5.2-15.xsl \
REC/test-5.2-16.xsl \
REC/test-5.2-17.xsl \
REC/test-5.2-18.xsl \
REC/test-5.2-2.xsl \
REC/test-5.2-3.xsl \
REC/test-5.2-4.xsl \
REC/test-5.2-5.xsl \
REC/test-5.2-6.xsl \
REC/test-5.2-7.xsl \
REC/test-5.2-8.xsl \
REC/test-5.2-9.xsl \
REC/test-5.3.xsl \
REC/test-5.4-1.xsl \
REC/test-5.4-2.xsl \
REC/test-5.4-3.xsl \
REC/test-5.4-4.xsl \
REC/test-5.4-5.xsl \
REC/test-5.8.xsl \
REC/test-6.xsl \
REC/test-7.1.1-2.xsl \
REC/test-7.1.1-3.xsl \
REC/test-7.1.1.xsl \
REC/test-7.1.3.xsl \
REC/test-7.1.4.xsl \
REC/test-7.3.xsl \
REC/test-7.4.xsl \
REC/test-7.5-1.xsl \
REC/test-7.6.1-1.xsl \
REC/test-7.6.1-2.xsl \
REC/test-7.6.1-3.xsl \
REC/test-7.6.2-1.xsl \
REC/test-7.7-1.xsl \
REC/test-7.7-2.xsl \
REC/test-7.7-3.xsl \
REC/test-7.7-4.xsl \
REC/test-7.7-5.xsl \
REC/test-8-1.xsl \
REC/test-9.1-1.xsl \
REC/test-9.1-2.xsl \
REC1/doc.xsl \
REC2/svg.xsl \
XSLTMark/alphabetize.xsl \
XSLTMark/avts.xsl \
XSLTMark/axis.xsl \
XSLTMark/bottles.xsl \
XSLTMark/brutal.xsl \
XSLTMark/chart.xsl \
XSLTMark/creation.xsl \
XSLTMark/current.xsl \
XSLTMark/dbonerow.xsl \
XSLTMark/dbtail.xsl \
XSLTMark/decoy.xsl \
XSLTMark/encrypt.xsl \
XSLTMark/functions.xsl \
XSLTMark/game.xsl \
XSLTMark/html.xsl \
XSLTMark/identity.xsl \
XSLTMark/inventory.xsl \
XSLTMark/metric.xsl \
XSLTMark/number.xsl \
XSLTMark/oddtemplate.xsl \
XSLTMark/patterns.xsl \
XSLTMark/prettyprint.xsl \
XSLTMark/priority.xsl \
XSLTMark/products.xsl \
XSLTMark/queens.xsl \
XSLTMark/stringsort.xsl \
XSLTMark/tower.xsl \
XSLTMark/trend.xsl \
XSLTMark/union.xsl \
XSLTMark/xpath.xsl \
XSLTMark/xslbench1.xsl \
documents/fragment.xsl \
documents/message.xsl \
extensions/list.xsl \
multiple/dict.xsl \
namespaces/extra.xsl \
namespaces/extra2.xsl \
namespaces/tst.xsl \
namespaces/tst2.xsl \
namespaces/tst3.xsl \
namespaces/tst4.xsl \
namespaces/tst5.xsl \
namespaces/tst6.xsl \
namespaces/tst8.xsl \
namespaces/tst9.xsl \
numbers/format-number.xsl \
reports/cmdlineparams.xsl \
xinclude/e.xsl

TEST_CASES_WITH_NO_INPUT = \
REC/article.xsl \
REC/bigfont.xsl \
REC/test-9.2-1.xsl \
XSLTMark/attsets.xsl \
XSLTMark/backwards.xsl \
XSLTMark/find.xsl \
XSLTMark/reverser.xsl \
XSLTMark/summarize.xsl \
XSLTMark/total.xsl \
XSLTMark/xslbench2.xsl \
XSLTMark/xslbench3.xsl \
documents/bredfort.xsl \
general/array.xsl \
general/bug-1-.xsl \
general/bug-2-.xsl \
general/bug-3-.xsl \
general/bug-4-.xsl \
general/bug-5-.xsl \
general/bug-6-.xsl \
general/bug-7-.xsl \
general/bug-8-.xsl \
general/bug-9-.xsl \
general/bug-10-.xsl \
general/bug-11-.xsl \
general/bug-12-.xsl \
general/bug-13-.xsl \
general/bug-14-.xsl \
general/bug-15-.xsl \
general/bug-16-.xsl \
general/bug-17-.xsl \
general/bug-18-.xsl \
general/bug-19-.xsl \
general/bug-20-.xsl \
general/bug-21-.xsl \
general/bug-22-.xsl \
general/bug-23-.xsl \
general/bug-24-.xsl \
general/bug-25-.xsl \
general/bug-26-.xsl \
general/bug-27-.xsl \
general/bug-28-.xsl \
general/bug-29-.xsl \
general/bug-30-.xsl \
general/bug-31-.xsl \
general/bug-32-.xsl \
general/bug-33-.xsl \
general/bug-35-.xsl \
general/bug-36-.xsl \
general/bug-36-inc.xsl \
general/bug-37-.xsl \
general/bug-37-inc.xsl \
general/bug-38-.xsl \
general/bug-39-.xsl \
general/bug-40-.xsl \
general/bug-41-.xsl \
general/bug-42-.xsl \
general/bug-43-.xsl \
general/bug-44-.xsl \
general/bug-45-.xsl \
general/bug-46-.xsl \
general/bug-47-.xsl \
general/bug-48-.xsl \
general/bug-49-.xsl \
general/bug-50-.xsl \
general/bug-52.xsl \
general/bug-53.xsl \
general/bug-54.xsl \
general/bug-55.xsl \
general/bug-56.xsl \
general/bug-57.xsl \
general/bug-59.xsl \
general/bug-60.xsl \
general/bug-61.xsl \
general/bug-62-inc.xsl \
general/bug-62.xsl \
general/bug-63.xsl \
general/bug-64.xsl \
general/bug-65.xsl \
general/bug-66.xsl \
general/bug-68.xsl \
general/bug-69.xsl \
general/bug-70.xsl \
general/bug-71.xsl \
general/bug-72.xsl \
general/bug-73.xsl \
general/bug-74.xsl \
general/bug-75.xsl \
general/bug-76.xsl \
general/bug-77.xsl \
general/bug-78.xsl \
general/bug-79.xsl \
general/bug-80.xsl \
general/bug-81.xsl \
general/bug-82.xsl \
general/bug-83.xsl \
general/bug-84.xsl \
general/bug-86.xsl \
general/bug-87.xsl \
general/bug-88.xsl \
general/bug-89.xsl \
general/bug-90.xsl \
general/bug-91.xsl \
general/bug-92.xsl \
general/bug-93-inc.xsl \
general/bug-93.xsl \
general/bug-94.xsl \
general/bug-95.xsl \
general/bug-96.xsl \
general/bug-97.xsl \
general/bug-98.xsl \
general/bug-99.xsl \
general/bug-100.xsl \
general/bug-101.xsl \
general/bug-102-inc.xsl \
general/bug-102.xsl \
general/bug-103.xsl \
general/bug-104.xsl \
general/bug-105.xsl \
general/bug-106.xsl \
general/bug-107.xsl \
general/bug-108.xsl \
general/bug-109.xsl \
general/bug-110.xsl \
general/bug-111.xsl \
general/bug-112.xsl \
general/bug-113.xsl \
general/bug-115.xsl \
general/bug-116.xsl \
general/bug-117.xsl \
general/bug-118.xsl \
general/bug-119.xsl \
general/bug-120.xsl \
general/bug-121.xsl \
general/bug-122.xsl \
general/bug-123.xsl \
general/bug-124.xsl \
general/bug-125.xsl \
general/bug-126.xsl \
general/bug-127.xsl \
general/bug-128.xsl \
general/bug-129.xsl \
general/bug-130.xsl \
general/bug-131.xsl \
general/bug-132.xsl \
general/bug-133.xsl \
general/bug-134.xsl \
general/bug-135.xsl \
general/bug-136.xsl \
general/bug-137.xsl \
general/bug-138.xsl \
general/bug-139.xsl \
general/bug-140.xsl \
general/bug-141.xsl \
general/bug-142.xsl \
general/bug-143.xsl \
general/bug-144.xsl \
general/bug-145.xsl \
general/bug-146.xsl \
general/bug-147.xsl \
general/bug-148.xsl \
general/bug-149.xsl \
general/bug-150.xsl \
general/bug-151.xsl \
general/bug-152.xsl \
general/bug-153.xsl \
general/bug-154.xsl \
general/bug-155.xsl \
general/bug-156.xsl \
general/bug-157.xsl \
general/bug-158.xsl \
general/bug-159.xsl \
general/bug-160.xsl \
general/bug-161.xsl \
general/bug-163.xsl \
general/bug-164.xsl \
general/bug-165.xsl \
general/bug-166.xsl \
general/character.xsl \
general/character2.xsl \
general/inner.xsl \
general/itemschoose.xsl \
xmlspec/REC-xml-2e.xsl \
xmlspec/diffspec.xsl \
xmlspec/xmlspec.xsl

# These scripts generate errors, so we skip them.
TEST_CASES_NOT_GOOD = \
REC2/html.xsl \
XSLTMark/tower2.xsl \
documents/test.xsl \
extensions/module.xsl \
general/bug-114.xsl \
general/bug-167.xsl \
keys/month.xsl \
namespaces/tst7.xsl \
plugins/plugin.xsl \
reports/recglobparam.xsl \
reports/recglobvar.xsl \
reports/reclocparam.xsl \
reports/reclocvar.xsl \
reports/tst-1.xsl \
reports/tst-2.xsl \
reports/undefvar.xsl

TEST_CASES = ${TEST_CASES_WITH_INPUT} ${TEST_CASES_WITH_NO_INPUT}

EXTRA_DIST_FILES = \
    ${TEST_CASES:.xsl=.xsl2} \
    ${TEST_CASES:.xsl=.slax} \
    ${TEST_CASES_WITH_INPUT:.xsl=.out} \
    ${TEST_CASES_WITH_INPUT:.xsl=.err} 

EXTRA_DIST = ${EXTRA_DIST_FILES}

CLEANDIRS = out

SLAXPROC=${top_builddir}/slaxproc/slaxproc

S2O = | ${SED} '1,/@@/d'
SPDEBUG=
S2X = ${CHECKER} ${SLAXPROC} ${SPDEBUG} --slax-to-xslt
X2S = ${CHECKER} ${SLAXPROC} ${SPDEBUG} --xslt-to-slax
SRUN = ${CHECKER} ${SLAXPROC} ${SPDEBUG} --run

testdir = ${WITH_LIBXSLT_TESTS}

all:

${SLAXPROC}:
	@(cd ${top_builddir}/slaxproc ; ${MAKE} slaxproc)

valgrind:
	@echo '## Running the regression tests under Valgrind'
	${MAKE} CHECKER='valgrind -q' tests

if USE_LIBXSLT_TESTS
test tests:
	@-${MKDIR} -p out out/documents out/keys out/xinclude out/multiple
	@-${CP} ${testdir}/documents/fragment2.xml out/documents/fragment2.xml
	@-${CP} ${testdir}/xinclude/x1.xml out/xinclude/x1.xml
	@-${CP} ${testdir}/multiple/dict.dtd out/multiple/dict.dtd
	@-(for test in ${TEST_CASES}; do \
	  base=`basename $$test .xsl` ; \
	  dir=`dirname $$test` ; \
	  echo ... $$test ... ; \
	  ${MKDIR} -p out/$$dir ; \
	  ${X2S} ${testdir}/$$test out/$$dir/$$base.slax ; \
	  ${S2X} out/$$dir/$$base.slax out/$$dir/$$base.xsl2 ; \
	  ${DIFF} -Nu ${srcdir}/$$dir/$$base.slax \
			out/$$dir/$$base.slax ${S2O}; \
	  ${DIFF} -Nu ${srcdir}/$$dir/$$base.xsl2 \
			out/$$dir/$$base.xsl2 ${S2O}; \
	  if [ -f ${srcdir}/$$dir/$$base.xml ]; then \
	    input=${srcdir}/$$dir/$$base.xml ; \
          else \
	    input=${testdir}/$$dir/$$base.xml ; \
	  fi ; \
	  if [ -f $$input ]; then \
	    ${SRUN} out/$$dir/$$base.slax $$input \
			> out/$$dir/$$base.out 2> out/$$dir/$$base.err ; \
	    if [ -f ${srcdir}/$$dir/$$base.out ]; then \
	      ${DIFF} -Nu ${srcdir}/$$dir/$$base.out \
			out/$$dir/$$base.out ${S2O} ; \
            else  \
	      ${DIFF} -Nu ${testdir}/$$dir/$$base.out \
			out/$$dir/$$base.out ${S2O} ; \
	    fi ; \
	    if [ -f ${srcdir}/$$dir/$$base.err ]; then \
	    ${DIFF} -Nu ${srcdir}/$$dir/$$base.err \
			out/$$dir/$$base.err ${S2O} ; \
	    else \
	      ${DIFF} -Nu ${testdir}/$$dir/$$base.err \
			out/$$dir/$$base.err ${S2O} ; \
	    fi ; \
	  fi ; \
	done)
endif

accept:
	@-(for test in ${TEST_CASES}; do \
	  base=`basename $$test .xsl` ; \
	  dir=`dirname $$test` ; \
	  ${MKDIR} -p ${srcdir}/$$dir ; \
	  ${CP} out/$$dir/$$base.slax ${srcdir}/$$dir/$$base.slax ; \
	  ${CP} out/$$dir/$$base.xsl2 ${srcdir}/$$dir/$$base.xsl2 ; \
	  if [ -f out/$$dir/$$base.out ]; then \
	    ${CP} out/$$dir/$$base.out ${srcdir}/$$dir/$$base.out ; \
	    ${CP} out/$$dir/$$base.err ${srcdir}/$$dir/$$base.err ; \
	  fi ; \
	done)

test-input:
	@echo TEST_CASES_WITH_INPUT =
	@-(for test in ${TEST_CASES}; do \
	  base=`basename $$test .xsl` ; \
	  dir=`dirname $$test` ; \
	  if [ -f ${srcdir}/$$dir/$$base.xml ]; then \
	    input=${srcdir}/$$dir/$$base.xml ; \
          else \
	    input=${testdir}/$$dir/$$base.xml ; \
	  fi ; \
	  if [ -f $$input ]; then \
	    echo $$test ; \
	  fi ; \
	done)
	@echo TEST_CASES_WITH_NO_INPUT =
	@-(for test in ${TEST_CASES}; do \
	  base=`basename $$test .xsl` ; \
	  dir=`dirname $$test` ; \
	  if [ -f ${srcdir}/$$dir/$$base.xml ]; then \
	    input=${srcdir}/$$dir/$$base.xml ; \
          else \
	    input=${testdir}/$$dir/$$base.xml ; \
	  fi ; \
	  if [ ! -f $$input ]; then \
	    echo $$test ; \
	  fi ; \
	done)
